//不允许多余的非空断言。 反例
interface BarType1 {
  bar: number;
}

const foo1: BarType1 | null = null;
export const bar1 = foo1!!!.bar;

export function foo2(bar: number | undefined) {
  const newBar: number = bar!!!;
  console.info(`${newBar}`);
}

interface BarType2 {
  n: number;
}

export function foo(bar?: BarType2) {
  return bar!?.n;
}

//ets反例
const foo: { bar: number } | null = null;
const bar = foo!!.bar;

function foo(bar: number | undefined) {
  const bar: number = bar!!;
}

function foo(bar?: { n: number }) {
  return bar!?.n;
}

function foo(bar?: { n: number }) {
  return bar!?.();
}

const foo: { bar: number } | null = null;
const bar = (foo!)!.bar;

function foo(bar?: { n: number }) {
  return (bar!)?.n;
}

function foo(bar?: { n: number }) {
  return (bar)!?.n;
}

function foo(bar?: { n: number }) {
  return (bar!)?.();
}